<template>
  <div>
    <button v-stream:click="play$">Play</button>
    <input type="text" v-model="energy">
    <br>
    <h1>{{ energy$ }}</h1>
  </div>
</template>

<script>
/* eslint-disable */
import { Observable } from 'rxjs'

export default {
  data() {
    return {
      energy: 12
    }
  },
  domStreams: ["play$"],
  subscriptions() {
    const energy$ = Observable.fromEvent(play$, 'click')
    .startWith(this.energy)
    .scan(time => time - 1)
    .takeWhile(time => time > 0)
    return {
      energy$
    }
  }
}
</script>

<style>

</style>
